#pragma once

template <class iterator,class Ref,class Ptr>
struct ReverseIterator
{
	typedef ReverseIterator<iterator, Ref, Ptr>self;
	iterator _cur;
	ReverseIterator(iterator it)
		:_cur(it)
	{}

	self& operator++()
	{
		--_cur;
		return *this;
	}
	self operator++(int)
	{
		self tmp = _cur;
		--_cur;
		return tmp;
	}
	self& operator--()
	{
		++_cur;
		return *this;
	}
	self operator--(int)
	{
		self tmp = _cur;
		--_cur;
		return tmp;
	}
	Ref operator*()
	{
		iterator tmp = _cur;
		--tmp;
		return *tmp;
	}

	Ptr operator->()
	{
		iterator tmp = _cur;
		--tmp;
		return &(*tmp);
	}

	bool operator==(const self&s)
	{
		return _cur = s._cur;
	}
	bool operator!=(const self&s)
	{
		return _cur != s._cur;
	}
};